home *** CD-ROM | disk | FTP | other *** search
- #include "wand_head.h"
-
- extern int edit_mode;
- extern char screen[NOOFROWS][ROWLEN+1];
-
- int rscreen(num,maxmoves)
- int *maxmoves, num;
- {
- int y;
- FILE *fp;
- char name[50];
- char (*row_ptr)[ROWLEN+1] = screen;
- if(!edit_mode)
- sprintf(name,"%s/screen.%d",SCREENPATH,num);
- else
- sprintf(name,"./screen");
- fp = fopen(name,"r");
- if(fp == NULL)
- printf("\nFile for screen %d unavailable.\n\n",num) ;
- else
- {
- for(y = 0;y<NOOFROWS;y++)
- {
- fgets((*row_ptr++),ROWLEN + 1,fp);
- fgetc(fp); /* remove newline char*/
- };
- if(fscanf(fp,"%*s\n%d",maxmoves) != 1)
- *maxmoves=0;
- fclose(fp);
- };
- return (fp == NULL);
- }
-
- int wscreen(num,maxmoves)
- int maxmoves, num;
- {
- int y,x;
- FILE *fp;
- char (*row_ptr)[ROWLEN+1] = screen;
- fp = fopen("./screen","w");
- if(fp == NULL)
- printf("\nFile for screen cannot be written.\n\n") ;
- else
- {
- for(y = 0;y<NOOFROWS;y++)
- {
- for(x = 0;x<ROWLEN;x++)
- fputc(row_ptr[y][x],fp);
- fputc('\n',fp);
- };
- for(x = 0; x<ROWLEN;x++)
- fputc('#',fp);
- fputc('\n',fp);
- if(maxmoves != 0)
- fprintf(fp,"%d\n",maxmoves);
- fclose(fp);
- };
- return (fp == NULL);
- }
-